import React, {Component} from 'react';
import {Route, Switch, Redirect} from 'react-router-dom';
import AuthManage from './content/AuthManage';
import Vehicle from './content/Vehicle';
import User from './content/User';
import Login from './content/Login';
import Article from './content/Article';
import Message from './content/Message';
import Operate from './content/yunying';
import Report from './content/Report';
import EditArticle from './content/Article/EditArticle';
import {Layout} from 'antd';
import {withRouter} from 'react-router-dom';
import {connect} from 'react-redux';
const {Content} = Layout;

class Main extends Component {
  render() {
    const {user} = this.props;
    return (
      <Content style={{display: 'flex'}}>
        <Switch>
          {user.role == 1 && (
            <Route path="/authManage" component={AuthManage} />
          )}
          {user.role == 1 && <Route path="/vehicle" component={Vehicle} />}
          {user.role == 1 && <Route path="/article" component={Article} />}
          {user.role == 1 && <Route path="/user" component={User} />}
          {user.role == 1 && <Route path="/report" component={Report} />}
          {user.role == 1 && <Route path="/operate" component={Message} />}
          {user.role == 1 ? <Redirect to="/operate" /> : null}
          {user.role == 0 ? <EditArticle /> : null}
        </Switch>
      </Content>
    );
  }
}
const mapStateToProps = state => {
  return {user: state.user};
};
export default withRouter(connect(mapStateToProps)(Main));
